<?php
/*
 * Action class for update user password(reset password) in profile view
 * @author Chamara Bandara
 * @copyright Copyright &copy; 2011 Allion Technologies (Pvt) Ltd
 */

class AjaxUpdatePasswordAction extends CAction {

   public function run() {
      if (Yii::app()->request->getIsAjaxRequest()) {
         $model = User::model()->loadModel($_POST['uid']);

         $model->password = User::model()->encryptPassword($_POST['npsw']);

         if (!$model->save()) {
            echo 'Invalid';
            exit;
         } else {
            echo 'valid';
            exit;
         }
      }
   }
}